/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.easoftware.code.beans.graphics;

import java.io.Serializable;
import java.util.List;

/**
 *
 * @author Clucero
 */
public class Graphics implements Serializable {

//    var s1 = [200, 600, 700, 1000];
//    var s2 = [460, -210, 690, 820];
    private String s1 = "100, 200, 500, 1000";
    private String s2 = "460, -30, 690, 820";
    private String ticks = "'Mayo', 'Junio', 'Julio', 'Agosto'";
    private String seriesName1 = "Exposicion mensual";
    private String seriesName2 = "Overdue Mensual";
    private String seriesName3 = "Overdue Mensual";
    private String hs1 = "300, 150, 500, 400,300, 150, 500, 400";
    private String hs2 = "460, 30, 690, 820,460, 30, 690, 820";
    private String hticks = "'Enero', 'Febrero', 'Marzo', 'Abril','Mayo', 'Junio', 'Julio'";
    private String hseriesName1 = "Exposicion Mensual";
    private String hseriesName2 = "Overdue Mensual";
    private String dataDonutGraphic = "['Credito 1', 12],['Petroleo x cobrar', 9], ['Light Industry', 14],"
            + "['Out of home', 16],['Commuting', 7], ['Orientation', 9]";
    private String dataDonutGraphic1 = "['Antiguedad 1', 6],['Petro x cobrar', 15], ['Light Industry', 14],"
            + "['Mora', 16],['Commuting', 7], ['Oritente', 9]";
    //grafica puntos
    private String title = "Titulo ";
    private String title1 = "Titulo1 ";
    private String arr1 = "2,3,4,5";
    private String arr2 = "6,7,8,9";
    private String arr3 = "4,2,6,8";
    private String arr4 = "2,3,2,5";
    private String arr5 = "2,3,5,5";
    private String arr6 = "2,3,7,9";
    //grafica barras y puntos
    private String pbarr1 = "['Ordenes 1', 7], ['Generic Fog Lamp', 9], ['HDTV Receiver', 15],"
            + "  ['8 Track Control Module', 12], [' Sludge Pump Fourier Modulator', 3], "
            + "  ['Transcender/Spice Rack', 6], ['Hair Spray Danger Indicator', 18]";
    private String pbarr2 = "['Nickle', 28], ['Aluminum', 13], ['Xenon', 54], ['Silver', 47], "
            + "  ['Sulfer', 16], ['Silicon', 14], ['Vanadium', 23]";
    //grafica barras y puntos 2
    private String pbarr3 = "['Cheques Rechazados', 7], ['Generic Fog Lamp', 9], ['HDTV Receiver', 15],"
            + "  ['8 Track Control Module', 12], [' Sludge Pump Fourier Modulator', 3],"
            + "  ['Transcender/Spice Rack', 6], ['Hair Spray Danger Indicator', 18]";
    private String pbarr4 = "['Recuperacion', 28], ['Aluminum', 13], ['Xenon', 54], ['Silver', 47], "
            + "  ['Sulfer', 16], ['Silicon', 14], ['Vanadium', 23]";
    //3 bars
    private String grpbar1 = "2, 6, 7, 10";
    private String grpbar2 = "7, 5, 3, 4";
    private String grpbar3 = "14, 9, 3, 8";

    public void generateHistogram(Histogram hist) {
        generateHistogram(createArrayCSV(hist.getValuesColumns()),
                createArrayCSV(hist.getValuesColumns1()),
                createAposString(hist.getNamesColums()),
                hist.getNameSerie(),
                hist.getNameSerie1());
    }

    public void generateHistogram1(Histogram hist) {
        generateHistogram1(createArrayCSV(hist.getValuesColumns()),
                createArrayCSV(hist.getValuesColumns1()),
                createAposString(hist.getNamesColums()),
                hist.getNameSerie(),
                hist.getNameSerie1());
    }

    public void generateDonut(List<Donut> lista) {
        String cadena = concatStringDonut(lista);
        this.dataDonutGraphic = cadena;
    }

    public void generateDonut1(List<Donut> lista) {
        String cadena = concatStringDonut(lista);
        this.dataDonutGraphic1 = cadena;
    }

    public void generatePointGraph(Point pointData) {
        generatePointGraph(pointData.getListDataPoint().toArray(),
                pointData.getListDataPoint1().toArray(),
                pointData.getListDataPoint2().toArray(), pointData.getTitle());
    }

    public void generatePointGraph1(Point pointData) {
        generatePointGraph1(pointData.getListDataPoint().toArray(),
                pointData.getListDataPoint1().toArray(),
                pointData.getListDataPoint2().toArray(), pointData.getTitle());
    }

    public void generateHistogram3Bar(Histogram3Bar hist) {
        generateGrp3BarGraph(hist.getValuesBar1().toArray(),
                hist.getValuesBar2().toArray(),
                hist.getValuesBar3().toArray());
    }

    public void generateBarrPoint(List<HistogramPoint> listBarr, List<HistogramPoint> listPoint) {
        this.pbarr1 = concatStringHistPoint(listBarr);
        this.pbarr2 = concatStringHistPoint(listPoint);
    }

    public void generateBarrPoint1(List<HistogramPoint> listBarr, List<HistogramPoint> listPoint) {
        this.pbarr1 = concatStringHistPoint(listBarr);
        this.pbarr2 = concatStringHistPoint(listPoint);
    }

    private void generateGrp3BarGraph(Object[] grpbar1, Object[] grpbar2, Object[] grpbar3) {
        this.setGrpbar1(createCSV(grpbar1));
        this.setGrpbar2(createCSV(grpbar2));
        this.setGrpbar3(createCSV(grpbar3));
    }

    private void generatePointGraph(Object[] arr1, Object[] arr2, Object[] arr3, String title) {
        this.arr1 = createCSV(arr1);
        this.arr2 = createCSV(arr2);
        this.arr3 = createCSV(arr3);
        this.title = title;
    }

    private void generatePointGraph1(Object[] arr1, Object[] arr2, Object[] arr3, String title) {
        this.arr4 = createCSV(arr1);
        this.arr5 = createCSV(arr2);
        this.arr6 = createCSV(arr3);
        this.title1 = title;
    }

    private void generateGrp3BarGraph(String[] grpbar1, String[] grpbar2, String[] grpbar3) {
        this.setGrpbar1(createCSV(grpbar1));
        this.setGrpbar2(createCSV(grpbar2));
        this.setGrpbar3(createCSV(grpbar3));
    }

    private void generatePointGraph(String[] arr1, String[] arr2, String[] arr3, String title) {
        this.arr1 = createCSV(arr1);
        this.arr2 = createCSV(arr2);
        this.arr3 = createCSV(arr3);
        this.title = title;
    }

    private void generateHistogram(String s1, String s2, String ticks, String seriesName1, String seriesName2) {
        this.s1 = s1;
        this.s2 = s2;
        //  this.s1 = "[".concat(s1).concat("]");
//        this.s2 = "[".concat(s2).concat("]");
        this.ticks = ticks;
        this.seriesName1 = seriesName1;
        this.seriesName2 = seriesName2;
    }

    private void generateHistogram1(String s1, String s2, String ticks, String seriesName1, String seriesName2) {
        this.hs1 = s1;
        this.hs2 = s2;
        //  this.hs1 = "[".concat(s1).concat("]");
        //this.hs2 = "[".concat(s2).concat("]");
        this.hticks = ticks;
        this.hseriesName1 = seriesName1;
        this.hseriesName2 = seriesName2;
    }

//    private void generateDonut(List<beanVal> lista){
//        String cadena = concatStringDonut(lista);
//       
//       this.dataDonutGraphic = cadena;
//        
//    }  
//    private void generateDonut1(List<beanVal> lista){
//        String cadena = concatStringDonut(lista);   
//        this.setDataDonutGraphic1(cadena);
//    }      
    public String getDataDonutGraphic() {
        return dataDonutGraphic;
    }

    public void setDataDonutGraphic(String dataDonutGraphic) {
        this.dataDonutGraphic = dataDonutGraphic;
    }

    public String getHs1() {
        return hs1;
    }

    public void setHs1(String hs1) {
        this.hs1 = hs1;
    }

    public String getHs2() {
        return hs2;
    }

    public void setHs2(String hs2) {
        this.hs2 = hs2;
    }

    public String getHticks() {
        return hticks;
    }

    public void setHticks(String hticks) {
        this.hticks = hticks;
    }

    public String getHseriesName1() {
        return hseriesName1;
    }

    public void setHseriesName1(String hseriesName1) {
        this.hseriesName1 = hseriesName1;
    }

    public String getHseriesName2() {
        return hseriesName2;
    }

    public void setHseriesName2(String hseriesName2) {
        this.hseriesName2 = hseriesName2;
    }

    public String getDataDonutGraphic1() {
        return dataDonutGraphic1;
    }

    public void setDataDonutGraphic1(String dataDonutGraphic1) {
        this.dataDonutGraphic1 = dataDonutGraphic1;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle1() {
        return title1;
    }

    public void setTitle1(String title1) {
        this.title1 = title1;
    }

    public String getArr1() {
        return arr1;
    }

    public void setArr1(String arr1) {
        this.arr1 = arr1;
    }

    public String getArr2() {
        return arr2;
    }

    public void setArr2(String arr2) {
        this.arr2 = arr2;
    }

    public String getArr3() {
        return arr3;
    }

    public void setArr3(String arr3) {
        this.arr3 = arr3;
    }

    public String getArr4() {
        return arr4;
    }

    public void setArr4(String arr4) {
        this.arr4 = arr4;
    }

    public String getArr5() {
        return arr5;
    }

    public void setArr5(String arr5) {
        this.arr5 = arr5;
    }

    public String getArr6() {
        return arr6;
    }

    public void setArr6(String arr6) {
        this.arr6 = arr6;
    }

    public String getPbarr1() {
        return pbarr1;
    }

    public void setPbarr1(String pbarr1) {
        this.pbarr1 = pbarr1;
    }

    public String getPbarr2() {
        return pbarr2;
    }

    public void setPbarr2(String pbarr2) {
        this.pbarr2 = pbarr2;
    }

    public String getPbarr3() {
        return pbarr3;
    }

    public void setPbarr3(String pbarr3) {
        this.pbarr3 = pbarr3;
    }

    public String getPbarr4() {
        return pbarr4;
    }

    public void setPbarr4(String pbarr4) {
        this.pbarr4 = pbarr4;
    }

    public String getGrpbar1() {
        return grpbar1;
    }

    public void setGrpbar1(String grpbar1) {
        this.grpbar1 = grpbar1;
    }

    public String getGrpbar2() {
        return grpbar2;
    }

    public void setGrpbar2(String grpbar2) {
        this.grpbar2 = grpbar2;
    }

    public String getGrpbar3() {
        return grpbar3;
    }

    public void setGrpbar3(String grpbar3) {
        this.grpbar3 = grpbar3;
    }

    public String getS1() {
        return s1;
    }

    public void setS1(String s1) {
        this.s1 = s1;
    }

    public String getS2() {
        return s2;
    }

    public void setS2(String s2) {
        this.s2 = s2;
    }

    public String getTicks() {
        return ticks;
    }

    public void setTricks(String tricks) {
        this.ticks = tricks;
    }

    public String getSeriesName1() {
        return seriesName1;
    }

    public void setSeriesName1(String seriesName1) {
        this.seriesName1 = seriesName1;
    }

    public String getSeriesName2() {
        return seriesName2;
    }

    public void setSeriesName2(String seriesName2) {
        this.seriesName2 = seriesName2;
    }

    public String createCSV(Object[] arr1) {
        String cadena = "";
        int i = 0;
        for (Object ob : arr1) {
            if (i > 0) {
                cadena = cadena.concat(",");
            }
            cadena = cadena.concat(String.valueOf(ob));
            i++;
        }
        return cadena;

//        for
    }

    public String concatStringDonut(List<Donut> lista) {
        String cadena = "";
        int i = 0;
        for (Donut val : lista) {
            cadena = i > 0 ? cadena.concat(",") : cadena;

            cadena = cadena.concat("[");
            cadena = cadena.concat("'").concat(val.getValue() + "% ").concat(val.getName()).concat("',");
            cadena = cadena.concat(String.valueOf(val.getValue()));
            cadena = cadena.concat("]");
            i++;
        }
        return cadena;
    }

    public String concatStringHistPoint(List<HistogramPoint> lista) {
        String cadena = "";
        int i = 0;
        for (HistogramPoint val : lista) {
            cadena = i > 0 ? cadena.concat(",") : cadena;

            cadena = cadena.concat("[");
            cadena = cadena.concat("'").concat(val.getName()).concat("',");
            cadena = cadena.concat(String.valueOf(val.getValue()));
            cadena = cadena.concat("]");
            i++;
        }
        return cadena;
    }

    public String createArrayCSV(List<Float> hist) {
        String cadena = "";
        int i = 0;
        for (Float val : hist) {
            cadena = i > 0 ? cadena.concat(",") : cadena;
            //cadena = cadena.concat("'").concat(String.valueOf(val)).concat("'");
            cadena = cadena.concat(String.valueOf(val));
            i++;
        }
        return cadena;
    }

    public String createAposString(List<String> list) {
        String value = "";
        for (String val : list) {
            value = value.concat("'".concat(val).concat("',"));
        }
        value = value.substring(0, value.length() - 1);
        return value;
    }

    public String getSeriesName3() {
        return seriesName3;
    }

    public void setSeriesName3(String seriesName3) {
        this.seriesName3 = seriesName3;
    }
}
